from typing import Optional

from apps.app_auth_provider.models import AuthProviderType, AuthProvider
from .base import BaseProvider, ProviderUserInfo
from .aai import AAIProvider
from .orcid import ORCIDProvider


__all__ = [
    'BaseProvider',
    'AAIProvider',
    'ORCIDProvider',
    'build_auth_provider',
    'ProviderUserInfo',
]


def build_auth_provider(auth_provider: AuthProvider) -> Optional[BaseProvider]:
    if auth_provider.provider_type == AuthProviderType.AAI.value:
        return AAIProvider(provider=auth_provider)
    elif auth_provider.provider_type == AuthProviderType.ORCID.value:
        return ORCIDProvider(provider=auth_provider)

    return None
